package com.wh.basic.config;



import com.wh.basic.handle.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 注册SpringMVC拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //.addPathPatterns("/**") //设置自定义拦截器作用与所有请求
                .excludePathPatterns("/login/**") //放行和登录有关的请求
                .excludePathPatterns("/minio/**") //放行和登录有关的请求
                .excludePathPatterns("/sse/**")//放行sse服务有关的请求
                .excludePathPatterns("/customMycustom/export") //放行和登录有关的请求
                .excludePathPatterns("/customMycustom/exportTemplate") //放行和登录有关的请求
                .excludePathPatterns("/customMycustom/mycustomerexport/*") //放行和登录有关的请求
                .excludePathPatterns("/HighseasCustom/importExcel") //放行和登录有关的请求
                .excludePathPatterns("/customMycustom/importExcel") //放行和登录有关的请求
                .excludePathPatterns("/customSalesmancustom/export") //放行和登录有关的请求
                .excludePathPatterns("/user/register/**","/verifyCode/**") //和注册有关的，验证码

             .excludePathPatterns("/doc.html", "/webjars/**", "/swagger-resources", "/v2/api-docs"); //放行swagger页面
    }
}